{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>添加达人</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">头像：</label>
                <div class="layui-input-block">
                    <input type="hidden" id="data_photo" name="images" >
                    <div id="imgPicker" style="float:left">选择图片</div>
                    <img id="img_data" height="100px" style="float:left;margin-left: 50px;margin-top: -10px;cursor:pointer;" src="/static/admin/images/no_img.jpg" onclick='imgDisplay(this)'/>
                    <div id="fileList" class="uploader-list" style="float:right"></div>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">姓名：</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">年龄：</label>
                <div class="layui-input-block">
                    <input type="number" min=1 name="age" lay-verify="required" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">身高：</label>
                <div class="layui-input-block">
                    <input type="text" name="height" lay-verify="required|realname"  class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">体重：</label>
                <div class="layui-input-block">
                    <input type="text" name="tz" lay-verify="required"  class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">联系方式：</label>
                <div class="layui-input-block">
                    <input type="text" disabled name="phone" lay-verify="required" class="layui-input"value="{$up_phone}">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">达人联系方式：</label>
                <div class="layui-input-block">
                    <input type="text" name="dr_phone" lay-verify="required|phone" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">领域：</label>
                <div class="layui-input-block">
                    <select name="goods" xm-select="select3"  lay-verify="required" xm-select-search="" xm-select-search-type="dl">
                        {volist name="realm" id="vo"}
                        <option value="{$vo['realm_id']}">{$vo['realm_name']}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                <label class="layui-form-label">简介：</label>
                <div class="layui-input-block" id="LAY_editor" lay-verify="editor">
                    <p></p>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">状态：</label>
                <div class="layui-input-block">
                    <input type="radio" name="super" value="2" checked title="超级达人" lay-filter="component-form-element1">
                    <input type="radio" name="super" value="1" title="普通达人"  lay-filter="component-form-element1">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8 jjgs">
                <label class="layui-form-label">经济公司：</label>
                <div class="layui-input-block">
                    <input type="text" name="jjgs" lay-verify="required" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8 jjgslxr">
                <label class="layui-form-label">经济公司联系人：</label>
                <div class="layui-input-block">
                    <input type="text" name="jjgslxr" lay-verify="required" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8 jj_phone">
                <label class="layui-form-label">经济公司联系人手机：</label>
                <div class="layui-input-block">
                    <input type="text" name="jj_phone" lay-verify="required" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                    <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="__JS__/Crop.js"></script>
<script type="text/javascript" src="__JS__/webupload/webuploader_upload.js"></script>
<script>
    wk.upload("{:url('Upload/uploadLocality')}",2);
    var editor = wk.wang({elem:'#LAY_editor'});

    //裁剪后的处理
    $("#sureCut").on("click",function () {
        if ($("#tailoringImg").attr("src") == null ){
            return false;
        }else{
            var cas = $('#tailoringImg').cropper('getCroppedCanvas');//获取被裁剪后的canvas
            var base64url = cas.toDataURL('image/png'); //转换为base64地址形式
            $("#img_data").attr('src',base64url).show();
            $('#data_photo').val(base64url);
            //关闭裁剪框
            layer.closeAll();
        }
    });
</script>
<script>
    layui.use(['form'], function() {
        var form = layui.form;
        form.on('radio(component-form-element1)', function(data){
            if(data.value==2){
                $(".jjgs").show();
                $(".jjgslxr").show();
                $(".jj_phone").show();
            }else{
                $(".jjgs").hide();
                $(".jjgslxr").hide();
                $(".jj_phone").hide();
            }
        });
        form.on('submit(component-form-element)', function (data) {
            data.field.jianjie = editor.txt.html();
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('add')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('doyen/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
</body>
</html>